#include <bits/stdc++.h>
using namespace std;
int t,n,m,l,x,d[100005],v[100005],a[100005],f1=0,f2=0,f3=0,p[100005],ans=0,rgt,fw;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for (int i=1;i<=t;i++){
        cin>>n>>m>>l>>x;
        ans=0;
        rgt=INT_MIN;
        for (int j=1;j<=n;j++){
            cin>>d[j]>>v[j]>>a[j];
            if (a[j]==0) f1=1;
            else if(a[j]<0) f2=1;
            else if (a[j]>0) f3=1;
        }
        for (int j=1;j<=m;j++){
            cin>>p[j];
        }
        if (f1==1&&f2==0&&f3==0) {
            for (int j=1;j<=n;j++){
               if (d[j]<=p[m]&&v[j]>x) ans++;
            }
            cout<<ans<<" ";
            if (ans==0) cout<<m<<endl;
            else cout<<m-1<<endl;
        }
        else if (f1==0&&f2==1&&f3==0){
            int f=0;
            int mapk=INT_MIN,mipk=INT_MAX;
            for (int j=1;j<=n;j++){
                if (v[j]<=x) continue ;
                f=0;
                mapk=INT_MIN,mipk=INT_MAX;
                for (int k=1;k<=m;k++){
                    if (p[k]>=d[j]&&p[k]<d[j]+(x*x-v[j]*v[j])*1.00/(2*a[j])){
                        f=1;
                        mapk=max(mapk,k);
                        mipk=min(mipk,k);
                        int temp=min(rgt,mipk);
                        rgt=max(rgt,mipk);
                        mipk=temp;
                        fw=abs(rgt-mipk)+1;

                    }
                }
                if (f==1) ans++;
            }
            cout<<ans<<" "<<m-fw<<endl;
        }
    }
    return 0;
}
